{extend name="_container/table"}
{block name="left"}
<a href="{:url('add')}" class="layui-btn iframe" data-title="添加翻译">添加翻译</a>
{/block}

{block name="right"}
<div class="layui-inline">
    <label class="layui-form-label">被翻译词语</label>
    <div class="layui-input-inline">
        <input type="text" name="from" autocomplete="off" value="{$Request.param.from}" class="layui-input">
    </div>
</div>
<div class="layui-inline">
    <button type="submit" class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search">
        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
    </button>
</div>
{/block}

{block name="table_header"}
<th>id</th>
<th>被翻译词语</th>
<th>翻译后词语</th>
<th>默认数据库字段类型</th>
<th>操作</th>
{/block}

{block name="table_body"}
<tr>
    <input type="hidden" name="id" value="{$v.id}">
    <td>{$v.id}</td>
    <td><input type="text" name="from" value="{$v.from}" style="text-align: center" class="layui-input"></td>
    <td><input type="text" name="to" value="{$v.to}" style="text-align: center" class="layui-input"></td>
    <td>
        <select name="type"  class="layui-select" style="text-align: center"  id="field_type"  >
            <option value="varchar" {$v.type=='varchar'?'selected':''}>varchar</option>
            <option value="int" {$v.type=='int'?'selected':''}>int</option>
            <option value="tinyint" {$v.type=='tinyint'?'selected':''}>tinyint</option>
            <option value="double" {$v.type=='double'?'selected':''}>double</option>
            <option value="char" {$v.type=='char'?'selected':''}>char</option>
            <option value="text" {$v.type=='text'?'selected':''}>text</option>
            <option value="longtext" {$v.type=='longtext'?'selected':''}>longtext</option>
            <option value="json" {$v.type=='json'?'selected':''}>json</option>
        </select>
    </td>
    <td>
        <span  class="layui-btn layui-btn-sm"  onclick="confirmUpdate(this)">确认修改</span>
        <span href="{:url('delete',['id'=>$v.id])}"  class="layui-btn layui-btn-sm ajax_del layui-btn-danger"  >删除</span>
    </td>
</tr>
{/block}

{block name="table_footer"}
{/block}

{block name="js"}
<script>
    function confirmUpdate(obj) {
        $.post('update',{
            from: $(obj).parents('tr').find("[name=from]").val(),
            to: $(obj).parents('tr').find("[name=to]").val(),
            type: $(obj).parents('tr').find("[name=type]").val(),
            id: $(obj).parents('tr').find("[name=id]").val(),
        },(data)=>{
            layer.msg(data.msg)
        })
    }
</script>
{/block}
{/extend}
